/* 业务逻辑 */
(function() {
	Path.on(["/__basename__.html", "/"], function() {
		App.set("$Cache.current_page", 1);
		//随机获取商品
		coAjax.get(appConfig.goods.list_random, {
			bus_id: busInfo._id,
			num: 12,
			page: 0
		}, function(result) {
			App.set("$Cache.main.random_goods", result.result);
		}, function() {
			console.log(arguments);
		});
	});

	// 获取分类树结构
	function _init_classify_tree() {
		coAjax.get(appConfig.bus_classify_tree, {
			bus_id: busInfo._id
		}, function(classify_tree) {
			App.set("$Cache.main.classify_tree", classify_tree.result);
			classify_tree.result.childs.forEach(function(classify, index) {
				coAjax.get(appConfig.bus_classify_all_child_goods_by_id + classify.classify._id, {
					bus_id: busInfo._id
				}, function(classify_info) {
					App.concat("$Cache.main.classify_list", [{
						_id: classify.classify._id,
						title: classify.classify.classify_name,
						contents: classify_info.result
					}]);
					App.set("$Cache.main.loading_tags_completed", true);
				});
			});
		});
	};
	_init_classify_tree();

	// 获取店铺列表
	// var remote_server_url = "http://121.40.18.23:1518/api/complex/ClientStoreMapFactory";

	// function _init_store_list() {
	// 	$.getJSON(remote_server_url, {
	// 		page_size: 12
	// 	}, function(store_list_result) {
	// 		App.set("$Cache.main.store_list", store_list_result.contents);
	// 	});
	// };
	// _init_store_list();




}());

/*交互*/
;